﻿using Bids.Core.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Metadata;
using Telerik.OpenAccess.Metadata.Fluent;
namespace Bids.Core.DomainObjects
{
	/// <summary>
	/// 收件箱
	/// </summary>
	[Serializable]
    public class InBox : IEntity
	{
		
		/// <summary>
		/// 
		/// </summary>
        public virtual int ID { set; get; }
		/// <summary>
		/// 发件人
		/// </summary>
        public virtual string Sender { set; get; }
		/// <summary>
		/// 收件人Id
		/// </summary>
        public virtual int UserId { set; get; }
		/// <summary>
		/// 标题
		/// </summary>
        public virtual string Title { set; get; }
		/// <summary>
		/// 正文
		/// </summary>
        public virtual string Content { set; get; }
		/// <summary>
		/// 时间
		/// </summary>
        public virtual DateTime CreateTime { set; get; }
		/// <summary>
		/// 状态
		/// </summary>
        public virtual int State { set; get; }

        public virtual InBoxStatus InBoxState
        {
            get
            {
                return (InBoxStatus)this.State;
            }
        }

        public static MappingConfiguration<InBox> CreateConfiguration()
        {
            var threadMapping = new MappingConfiguration<InBox>();
            threadMapping.MapType(t => new
            {
                t.ID,
                t.Sender,
                t.UserId,
                t.Title,
                t.Content,
                t.CreateTime,
                t.State
            }).ToTable("InBoxes");
            threadMapping.HasProperty(t => t.ID).IsIdentity(KeyGenerator.Autoinc);
            return threadMapping;
        }
	}
    public enum InBoxStatus
    {
        未读 = 1,
        已读 = 2
    }
}

